﻿/**
* @author Alexander Rindo
* @project Flashview
* @version 0.4
* @purpose Class for the InformationBar Movieclip
**/

package com.alexrindo.flashview.UI.information 
{
	import com.alexrindo.flashview.data.GalleryData;
	import com.alexrindo.flashview.image.ImageManager;
	import flash.display.MovieClip;
	import flash.events.Event;
	
	public class InformationBar extends MovieClip
	{
		private var _images:ImageManager
		private var _data:GalleryData
		
		public function InformationBar() 
		{
			setup()
			setInformation()
		}
		
		private function setup():void
		{
			_data = GalleryData.getInstance()
			_images = ImageManager.getInstance()
			
			_images.addEventListener(ImageManager.IMAGE_CHANGE, updateInformation)
			_images.addEventListener(ImageManager.FRAME_CHANGE, updateInformation)
			_images.addEventListener(ImageManager.IMAGE_ZOOM, updateInformation)
		}
		
		private function setInformation():void
		{
			if (_images.getCurrentImageType() == "gif")
			{
				gotoAndStop(2)
				GIFcurrentFrame.text = _images.getCurrentImageFrame().toString()
				GIFtotalFrames.text = _images.getCurrentImageFramesTotal().toString()
			} else {
				gotoAndStop(1)
			}
			
			ImageName.text = _data.getName(_images.index)
			ImageSize.text = _images.getCurrentImageSize() + " kb"
			ImageType.text = _images.getCurrentImageType().toUpperCase()
			Dimensions.text = _images.getCurrentImageDimensions()
		}
		
		public function updateInformation(e:Event):void
		{
			setInformation()
		}
	}
}